Directed Percolation Simulation Example¶

This notebook demonstrates how to use the DirectedPercolation module to simulate the model and visualize the results.

Project Setup¶

Your directory structure should now look like this:

your_project_folder/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ Directed_Percolation.jl
│   ā”œā”€ā”€ State_Evol.jl
│   └── Plots_Helpers.jl
ā”œā”€ā”€ example.ipynb
└── Project.toml
InĀ [1]:
using Pkg
Pkg.activate(".")
Pkg.add(["Plots", "Statistics"])
  Activating project at `~/GitHub/Directed_Percolation`
   Resolving package versions...
  No Changes to `~/GitHub/Directed_Percolation/Project.toml`
  No Changes to `~/GitHub/Directed_Percolation/Manifest.toml`

Loading the Module and Dependencies¶

InĀ [2]:
include("src/Directed_Percolation.jl")
using .DirectedPercolation
using Random
using Plots

Main Execution¶

InĀ [3]:
Random.seed!(1234)

# --- Parameters for the density vs. time plot ---
N_time_plot = 100
p_time_plot = 0.7
q_time_plot = 0.8
t_max_time_plot = 200
num_trials_time_plot = 50

plot1 = plot_density_vs_time(N_time_plot, p_time_plot, q_time_plot, t_max_time_plot, num_trials_time_plot)
# savefig(plot1, "density_vs_time.png")
display(plot1)
Generating plot for p=0.7, q=0.8...
No description has been provided for this image

Debugging Plot: Staggered Lattice Structure¶

This plot shows the underlying bond structure of the staggered lattice, which is useful for verifying the geometry of the simulation.

InĀ [4]:
# --- Parameters for the lattice plots ---
N_lattice = 100
t_max_lattice = 100

debug_plot = plot_staggered_lattice_grid(N_lattice, t_max_lattice)
display(debug_plot)
No description has been provided for this image

Lattice Evolution Plot¶

InĀ [Ā ]:
# --- Parameters for a single lattice evolution run ---
p_lattice = 0.75
q_lattice = 0.80


initial_state_lattice = generate_initial_state(N_lattice, density=0.3)

history = evolve(N_lattice, p_lattice, q_lattice, t_max_lattice, initial_state_lattice)

plot_lattice = plot_lattice_evolution(history, dpi=600)
# savefig(plot_lattice, "lattice_evolution.png")
display(plot_lattice)
No description has been provided for this image
InĀ [6]:
# --- Parameters for the phase diagram ---
N_phase = 100
t_final_phase = 100
p_steps_phase = 100
q_steps_phase = 100
num_trials_phase = 10

plot2 = plot_phase_diagram(N_phase, t_final_phase, p_steps_phase, q_steps_phase, num_trials_phase)
# savefig(plot2, "phase_diagram.png")
display(plot2)
Generating phase diagram...
Progress: 10.0%
Progress: 20.0%
Progress: 30.0%
Progress: 40.0%
Progress: 50.0%
Progress: 60.0%
Progress: 70.0%
Progress: 80.0%
Progress: 90.0%
Progress: 100.0%
No description has been provided for this image
InĀ [7]: